<?php
/* 缓存保存token */
$mmc = memcache_init();
$access_token = memcache_get($mmc, "token");

if(empty($access_token)){

	$appid = 'wx74578237cbd08f3b';
	$secret = '37e84aea25576b17bfee8e14be597e43';

	$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

	$a = curl_exec($ch);
	$strjson = json_decode($a);

	$token = $strjson->access_token;

	memcache_set($mmc, "token", $token, 0, 7100);

	$access_token = memcache_get($mmc, "token");

}
?>